﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:FinMkts.Client.Controls">

    <!-- ClippingBorder style -->
    <Style TargetType="local:ClippingBorder">
        <Setter Property="ClipContent" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ClippingBorder">
                    <Border Background="{TemplateBinding Background}" 
                            CornerRadius="{TemplateBinding CornerRadius}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            x:Name="PART_Border">
                        <Grid>
                            <ContentControl x:Name="PART_TopLeftContentControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                                <ContentControl.Clip>
                                    <RectangleGeometry x:Name="PART_TopLeftClip" />
                                </ContentControl.Clip>
                                <ContentControl x:Name="PART_TopRightContentControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >
                                    <ContentControl.Clip>
                                        <RectangleGeometry x:Name="PART_TopRightClip" />
                                    </ContentControl.Clip>
                                    <ContentControl x:Name="PART_BottomRightContentControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >
                                        <ContentControl.Clip>
                                            <RectangleGeometry x:Name="PART_BottomRightClip" />
                                        </ContentControl.Clip>
                                        <ContentControl x:Name="PART_BottomLeftContentControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >
                                            <ContentControl.Clip>
                                                <RectangleGeometry x:Name="PART_BottomLeftClip" />
                                            </ContentControl.Clip>
                                            <ContentPresenter Margin="{TemplateBinding Padding}" />
                                        </ContentControl>
                                    </ContentControl>
                                </ContentControl>
                            </ContentControl>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- OuterGlowBorder style -->
    <Style TargetType="local:OuterGlowBorder">
        <Setter Property="OuterGlowSize" Value="10" />
        <Setter Property="OuterGlowOpacity" Value="0.5" />
        <Setter Property="OuterGlowColor" Value="#ff000000" />
        <Setter Property="ClipContent" Value="True" />        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:OuterGlowBorder">
                    <Grid>
                        <Border Opacity="{TemplateBinding OuterGlowOpacity}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                                   CornerRadius="{TemplateBinding ShadowCornerRadius}" x:Name="PART_OuterGlowBorder" IsHitTestVisible="False" >
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" MappingMode="RelativeToBoundingBox">
                                    <GradientStop Color="#00000000" Offset="0" x:Name="PART_ShadowOuterStop1" />
                                    <GradientStop Color="#ff000000" Offset="0.1" x:Name="PART_ShadowVertical1"/>
                                    <GradientStop Color="#ff000000" Offset="0.9" x:Name="PART_ShadowVertical2"/>
                                    <GradientStop Color="#00000000" Offset="1" x:Name="PART_ShadowOuterStop2" />
                                </LinearGradientBrush>
                            </Border.Background>
                            <Border.OpacityMask>
                                <LinearGradientBrush EndPoint="1.0,0.5" StartPoint="0.0,0.5" MappingMode="RelativeToBoundingBox">
                                    <GradientStop Color="#00000000" Offset="0"/>
                                    <GradientStop Color="#FF000000" Offset="0.1" x:Name="PART_ShadowHorizontal1"/>
                                    <GradientStop Color="#FF000000" Offset="0.9" x:Name="PART_ShadowHorizontal2"/>
                                    <GradientStop Color="#00000000" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.OpacityMask>
                        </Border>
                        <local:ClippingBorder Background="{TemplateBinding Background}" 
                                CornerRadius="{TemplateBinding CornerRadius}"
                                Padding="{TemplateBinding Padding}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                ClipContent="{TemplateBinding ClipContent}">
                            <ContentPresenter />
                        </local:ClippingBorder>


                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- InnerGlowBorder style -->
    <Style TargetType="local:InnerGlowBorder">
        <Setter Property="InnerGlowSize" Value="10,10,10,10" />
        <Setter Property="InnerGlowOpacity" Value="0.5" />
        <Setter Property="InnerGlowColor" Value="#ff000000" />
        <Setter Property="ClipContent" Value="True" />
        <Setter Property="ContentZIndex" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:InnerGlowBorder">
                    <local:ClippingBorder Background="{TemplateBinding Background}" 
                            CornerRadius="{TemplateBinding CornerRadius}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            ClipContent="{TemplateBinding ClipContent}">
                        <Grid>

                            <ContentPresenter Margin="{TemplateBinding Padding}" Canvas.ZIndex="{TemplateBinding ContentZIndex}" />

                            <Border x:Name="PART_LeftGlow" IsHitTestVisible="False" Canvas.ZIndex="0"
                                    Opacity="{TemplateBinding InnerGlowOpacity}"
                                    HorizontalAlignment="Left" VerticalAlignment="Stretch"
                                    Width="10">
                                <Border.Background>
                                    <LinearGradientBrush StartPoint="0, 0.5" EndPoint="1, 0.5">
                                        <GradientStop Offset="0" Color="#ff000000" x:Name="PART_LeftGlowStop0" />
                                        <GradientStop Offset="1" Color="#00000000" x:Name="PART_LeftGlowStop1" />
                                    </LinearGradientBrush>
                                </Border.Background>
                            </Border>
                            <Border x:Name="PART_TopGlow" IsHitTestVisible="False" Canvas.ZIndex="0"
                                    Opacity="{TemplateBinding InnerGlowOpacity}"
                                    HorizontalAlignment="Stretch" VerticalAlignment="Top"
                                    Height="10">
                                <Border.Background>
                                    <LinearGradientBrush StartPoint="0.5, 0" EndPoint="0.5, 1">
                                        <GradientStop Offset="0" Color="#ff000000" x:Name="PART_TopGlowStop0" />
                                        <GradientStop Offset="1" Color="#00000000" x:Name="PART_TopGlowStop1" />
                                    </LinearGradientBrush>
                                </Border.Background>
                            </Border>
                            <Border x:Name="PART_RightGlow" IsHitTestVisible="False" Canvas.ZIndex="0"
                                    Opacity="{TemplateBinding InnerGlowOpacity}"
                                    HorizontalAlignment="Right" VerticalAlignment="Stretch"
                                    Width="10">
                                <Border.Background>
                                    <LinearGradientBrush StartPoint="1, 0.5" EndPoint="0, 0.5">
                                        <GradientStop Offset="0" Color="#ff000000" x:Name="PART_RightGlowStop0" />
                                        <GradientStop Offset="1" Color="#00000000" x:Name="PART_RightGlowStop1" />
                                    </LinearGradientBrush>
                                </Border.Background>
                            </Border>
                            <Border x:Name="PART_BottomGlow" IsHitTestVisible="False" Canvas.ZIndex="0"
                                    Opacity="{TemplateBinding InnerGlowOpacity}"
                                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
                                    Height="10">
                                <Border.Background>
                                    <LinearGradientBrush StartPoint="0.5, 1" EndPoint="0.5, 0">
                                        <GradientStop Offset="0" Color="#ff000000" x:Name="PART_BottomGlowStop0" />
                                        <GradientStop Offset="1" Color="#00000000" x:Name="PART_BottomGlowStop1" />
                                    </LinearGradientBrush>
                                </Border.Background>
                            </Border>
                        </Grid>
                    </local:ClippingBorder>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DraggablePanel style -->
    <Style TargetType="local:DraggablePanel">
        <Setter Property="Background" Value="#ff000000" />
        <Setter Property="BorderBrush" Value="#ff333333" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:DraggablePanel">
                    <Grid>
                        <!-- Border with white background -->
                        <local:OuterGlowBorder 
                            OuterGlowOpacity="0.4" OuterGlowSize="15"
                            CornerRadius="3,3,3,3" 
                            Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                    >
                            <local:InnerGlowBorder
                                    InnerGlowOpacity="1" CornerRadius="3,3,3,3" InnerGlowColor="#11ffffff" InnerGlowSize="15,15,0,0" Margin="0" Padding="2" ClipContent="True"
                                    Background="Transparent" BorderThickness="0">
                                <Grid>

                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>

                                    <!-- Content presenter for hosting the content -->
                                    <ContentPresenter Grid.Row="1"
                                                      Content="{TemplateBinding Content}"
                                                      ContentTemplate="{TemplateBinding ContentTemplate}"/>

                                    <!-- 
                  Element named PART_GripBar for 
                  handling the dragging of the panel  
                  -->

                                    <!--Background="#7f000000"-->
                                    <Border Background="WhiteSmoke" Margin="0" Padding="3">
                                        <Grid>
                                            <Border x:Name="GripBarElement"   CornerRadius="3,3,0,0" Background="#00ffffff" VerticalAlignment="Top" MinHeight="20" Cursor="Hand"
                                            Margin="0,0,0,0" IsHitTestVisible="{TemplateBinding DraggingEnabled}">
                                                <Grid>
                                                    <Rectangle Opacity="0.5" >
                                                        <Rectangle.Fill>
                                                            <LinearGradientBrush EndPoint="6.58300018310547,6.08300018310547" StartPoint="2.31500005722046,1.81500005722046" 
                                           SpreadMethod="Repeat" MappingMode="Absolute">
                                                                <GradientStop Color="#FFAFAFAF" Offset="0"/>
                                                                <GradientStop Color="#00FFFFFF" Offset="1"/>
                                                                <GradientStop Color="#00FFFFFF" Offset="0.339"/>
                                                            </LinearGradientBrush>
                                                        </Rectangle.Fill>
                                                    </Rectangle>
                                                    <ContentPresenter Content="{TemplateBinding Header}" 
                                                              ContentTemplate="{TemplateBinding HeaderTemplate}" />

                                                </Grid>
                                            </Border>
                                        </Grid>
                                    </Border>
                                </Grid>
                            </local:InnerGlowBorder>
                        </local:OuterGlowBorder>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="{Binding}"
                                FontFamily="Verdana"
                                FontSize="12"
                                VerticalAlignment="Center"
                                Margin="5"
                                Foreground="Black"
                                HorizontalAlignment="Center"
                        />
                    <!--Foreground="#ffffffff"-->
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
